package com.zimin.cloud.gateway.config;

import com.zimin.common.constant.ServletConstant;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

/**
 * @author zimin
 * @since 2022/3/28 4:32 下午
 * 网关配置
 */
@Component
public class GatewayConfig implements WebFluxConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowCredentials(Boolean.TRUE)
                .allowedMethods(ServletConstant.GET, ServletConstant.POST, ServletConstant.PUT, ServletConstant.DELETE)
                .allowedHeaders("*")
                .maxAge(3600);
    }
}
